<template>
	<view class="wallet">
		<view class="wallet_head">
			<view class="wallet_total">
				<view class="total_sign">¥</view>
				<view class="total_num">{{money_userInfo.commission?money_userInfo.commission:'0.00'}}</view>
			</view>
			<view class="total_title">佣金总额（元）</view>
		</view>
		<view class="wallet_detail">
			<view class="wallet_nav flex ali-c jus-a">
				<!-- <view class="navigation" :class="{active:select==1}" @tap="tabto(1)">账户明细</view> -->
				<view class="navigation flex1 flexc" :class="{active:select==1}" @tap="tabto(1)">佣金收入</view>
				<view class="navigation flex1 flexc" :class="{active:select==-1}" @tap="tabto(-1)">佣金支出</view>
			</view>
			<view class="wallet_list" v-for="(item,index) in userDetailMoneys" :key="index">
				<view class="wallet_info">
					<view class="info_title twoline flex1">{{item.intro}}</view>
					<view class="info_num ">
						<view class="num_money">{{item.money}}</view>
						<view class="num_time">{{item.recorded_time}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="none_more">没有更多了</view>
		
		<navigator url="/pages/mine/withdrawal/withdrawal" hover-class="none" class="cash_out">
			<view class="cash_btn">提现</view>
		</navigator>
	</view>
</template>

<script>
	import {deatailMoneyLog} from "@/utils/api/user.js";
	export default{
		data(){
			return{
				select:1,
				page:0,
				money_userInfo:{},
				userDetailMoneys:[],
				isshowall:false,
			}
		},
		onLoad() {
			this.deatailMoneyLogfun();
		},
		onReachBottom() {
			if(!this.isshowall){
				this.deatailMoneyLogfun();
			}
		},
		methods:{
			tabto(item){
				if(this.select==item){
					return false;
				}
				this.select = item;
				this.page = 0;
				this.isshowall = false;
				this.userDetailMoneys = [];
				this.deatailMoneyLogfun();
			},
			async deatailMoneyLogfun(){
				this.page++;
				let res = await deatailMoneyLog({
					type:3,//type 资金类型，1=用户余额，2=代理资金，3=佣金
					heatos:this.select,//1=收入，-1=支出
					page:this.page,
				})
				if(res.code==1){
					this.money_userInfo = res.data.userInfo;
					this.userDetailMoneys = [...this.userDetailMoneys,...res.data.userDetailMoneys];
					if(res.data.userDetailMoneys.length==0){
						this.isshowall = true;
						if(this.page>1){
							this.$api.msg("没有更多了~");
						}
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	@import "./wallet.scss";
</style>